package net.liteheaven.xblib.plugin;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

/**
 * 插件活动启动帮助类
 *
 * Created by LiangYu on 16/8/29
 */
public class XActivityUtil {

    public static final String PLUGIN_PATH = "_plugin_apk_path";
    public static final String PLUGIN_ACTIVITY_NAME = "_plugin_activity_name";

    public static void startActivity(Context ctx, String path, Intent intent){
        String className = intent.getComponent().getClassName();
        if (TextUtils.isEmpty(className)){
            throw new IllegalArgumentException("活动名不允许为空");
        }
        intent.putExtra(PLUGIN_ACTIVITY_NAME, className);

        intent.putExtra(PLUGIN_PATH, path);

        intent.setClass(ctx, XProxyActivity.class);
        ctx.startActivity(intent);
    }
}
